load("@fbcode//eden:defs.bzl", "make_rule_compatible_with")
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("@fbcode_macros//build_defs:thrift_library.bzl", "thrift_library")

oncall("scm_client_infra")

cpp_library(
    name = "config",
    srcs = glob(["*.cpp"]),
    headers = glob(["*.h"]),
    deps = [
        "//eden/common/utils:bug",
        "//eden/common/utils:enum",
        "//eden/common/utils:file_utils",
        "//eden/common/utils:system_error",
        "//eden/common/utils:user_info",
        "//eden/fs/utils:filter_utils",
        "//folly:map_util",
        "//folly:range",
        "//folly:string",
        "//folly/io:iobuf",
        "//thrift/lib/cpp/util:enum_utils",
    ],
    exported_deps = [
        "fbsource//third-party/cpptoml:cpptoml",
        "fbsource//third-party/fmt:fmt",
        "fbsource//third-party/re2:re2",
        ":config_thrift-cpp2-types",
        "//common/rust/shed/hostcaps:hostcaps_ffi",
        "//eden/common/utils:case_sensitivity",
        "//eden/common/utils:option_set",
        "//eden/common/utils:path",
        "//eden/common/utils:throw",
        "//eden/common/utils:utils",
        "//eden/fs:config",
        "//eden/fs/model:model",
        "//eden/fs/store:store_type",
        "//eden/fs/utils:chrono",
        "//folly:expected",
        "//folly:file",
        "//folly:file_util",
        "//folly:portability",
        "//folly:utility",
        "//folly/concurrency/memory:atomic_read_mostly_main_ptr",
        "//folly/json:dynamic",
        "//folly/logging:logging",
        "//folly/portability:sys_types",
        "//thrift/lib/cpp/concurrency:thread_manager",
    ],
    external_deps = [
        ("boost", None, "boost_filesystem"),
    ],
)

thrift_library(
    name = "config_thrift",
    languages = [
        "cpp2",
        "java-swift",
        "py3-deprecated",
        "python",
        "rust",
        "py-deprecated",
    ],
    py_base_module = "facebook.eden",
    thrift_rust_options = ["deprecated_default_enum_min_i32"],
    thrift_srcs = {
        "eden_config.thrift": [],
    },
)

# The Java bindings are only used by Buck, and since Buck is in a separate repo,
# they are manually compiled and copied. See the build instructions in
# eden/fs/service/TARGETS.
#
# TODO: Sandcastle macOS is not yet configured to build Java targets, so disable
# this on macOS.
make_rule_compatible_with(
    name = "config_thrift_buck",
    compatible_with = [
        "ovr_config//os:linux",
    ],
    labels = ["noautodeps"],
    languages = [
        "javadeprecated",
    ],
    rule = thrift_library,
    thrift_srcs = {
        "eden_config.thrift": [],
    },
)
